<?php

class VenueController extends Zend_Controller_Action
{
	protected $_session;
	
    public function init()
    {
    	//read the session.
        $storage = new Zend_Auth_Storage_Session();
		$session = $storage->read();
		//there is no data in session, then direct to login action
		if(!$session){
			$this->_redirect('auth/login');
		}
		//there is data in session, show the user's information
		$this->_session = $session;
    }

    public function indexAction()
    {
        // action body
    }

	public function universitiesAction(){
		
		$venuesMapper = new Model_VenuesMapper();
		//get the universities from database.
		$universities = $venuesMapper->findUnversities();
		//send the session to view.
		$this->view->session = $this->_session;
		//send the universities to view.
		$this->view->data = $universities;
	}
	
	public function getchildreninfoAction(){
		
		//get the venue id.
		$venueId = $_REQUEST['venue_id'];
		$venuesMapper = new Model_VenuesMapper();
		//get the children venue of the venue provided.
		$venues = $venuesMapper->findChildrenInfo($venueId);
		//send session and venues to view.
		$this->view->session = $this->_session;
		$this->view->data = $venues;
	}
}

